package com.ui.swing;

import java.awt.Container;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JTextArea;

public class AboutDialog extends JDialog {
	
	private JTextArea txtAbout = new JTextArea();
    private JPanel ctrlPane = new JPanel();
    private JButton btnOK = new JButton();
	
    public AboutDialog(Frame owner) {
    	super(owner, true);
    	initUI();
    	
    	pack();
    	Dimension d1 = getSize();
		Dimension d2 = owner.getSize();
		Point p = owner.getLocation();
		setLocation((d2.width-d1.width)/2+p.x, (d2.height-d1.height)/2+p.y);
    }
    
    private void initUI() {
    	Container c = getContentPane();
    	
    	c.add(txtAbout, java.awt.BorderLayout.CENTER);
    	c.add(ctrlPane, java.awt.BorderLayout.SOUTH);
    	
    	txtAbout.setEditable(false);
    	txtAbout.setText("\n Tidemark version alpha 0.1. " +
    			"\n\n Copyright 2009 MXX & LJH" +
    			"\n\n Thank you for support this software." +
    			"\n");
    	btnOK.setText("OK");
        ctrlPane.add(btnOK);
        
        btnOK.addActionListener(new ActionListener() {
        	public void actionPerformed(ActionEvent evt) {
        		dispose();
        	}
        });
    }
}
